package com.baselib.libnetwork.net.request;

import okhttp3.Request;
import okhttp3.RequestBody;

/**
 * @author lixuce
 * @version v1.0
 * @description
 * @since 2017/10/29
 */

public class PostRequest<T> extends FileRequest<T, PostRequest<T>> {

    public PostRequest(String url) {
        super(url);
    }

    @Override
    public PostRequest<T> retryCount(int retryCount) {
        return super.retryCount(1);
    }

    @Override
    public Request generateRequest(RequestBody requestBody) {
        Request.Builder requestBuilder = generateRequestBuilder(requestBody);
        if (file == null) {
            requestBuilder.addHeader("content-type", "application/x-www-form-urlencoded");
        } else {
            requestBuilder.addHeader("content-type", "multipart/form-data");
        }
        return requestBuilder.post(requestBody).url(url).tag(tag).build();
    }

}
